<template>
  <div>
       <img src="../../assets/logo.png">
        <span id="test">用户名:</span><input type="text" v-model="userInfo.userName">
        密码:<input type="password" v-model="userInfo.userPwd">
        <button type="button" @click="login">登录</button>
       <button type="button" @click="loginPost">登录post</button>

       <el-button>测试</el-button>

  </div>

</template>

<script>
  /*导入自定义的js*/
  import {test01,num} from "../../assets/test";

  export default {
        name: "Demo01",//描述组件名称
        data(){
           return{
               userInfo:{
                    userName:"",
                    userPwd:""
               }
           }
        },
       methods:{//定义函数
          login() {
              //alert(this.userInfo.userName);
              //test01();
             //1 发送ajax请求
             const http = this.$http.get("/server-register/userInfo/test",{params:this.userInfo});
            //2 定义请求的回调函数
             http.then(function (rs) {
                  console.log(rs.data.msg);
            })
          },
         loginPost(){//post登录
            const self = this;
           const http = this.$http.post("/server-register/userInfo/testPost",this.userInfo);
           //2 定义请求的回调函数
           http.then(function (rs) {
             console.log(rs.data.msg);
             self.$message(rs.data.msg);

           })
         }
       }
    }
</script>

<style >
  @import url(../../assets/test.css);
</style>
